﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
using Volo.Abp;
using Volo.Abp.Domain.Values;

namespace Mozhi.Abp.Domain.BasicData
{
    public class ProductAuxiliaryUnit : ValueObject
    {
        [JsonProperty]
        public virtual Guid ProductId { get; protected set; }

        [JsonProperty]
        public virtual Guid BasicUnitId { get; protected set; }

        [JsonProperty]
        public virtual Guid OtherUnitId { get; protected set; }

        [JsonProperty]
        public virtual decimal ConversionRate { get; protected set; }

        [JsonProperty]
        public virtual bool Activated {  get; protected set; }

        [JsonProperty]
        public string BasicUnitName {  get; protected set; }

        [JsonProperty]
        public string OtherUnitName { get; protected set; }

        [JsonProperty]
        public string ProductCode {  get; protected set; }

        [JsonProperty]
        public string ProductName {  get; protected set; }

        public virtual void Validate()
        {
            if (!Activated)
                throw new UserFriendlyException($"产品辅助单位换算已禁用", "100000");
        }

        protected override IEnumerable<object> GetAtomicValues()
        {
            throw new NotImplementedException();
        }
    }
}
